﻿using Furion.JsonSerialization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.HttpResults;
using Newtonsoft.Json.Serialization;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TcpClient.Application.System.Dtos.Login;
using static System.Runtime.InteropServices.JavaScript.JSType;

namespace TcpClient.Application.System.Login
{
    /// <summary>
    /// 登录
    /// </summary>
    public class LoginAppService : IDynamicApiController
    {
        public async Task<LoginDto> GetLogin()
        {
            string name = "111";
            string pas = "111";
            // token
            var accessToken = JWTEncryption.Encrypt(new Dictionary<string, object>()
            {
                { "UserId", name },  // 存储Id
                { "Account",pas }, // 存储用户名
            });

            // 获取刷新 token
            var refreshToken = JWTEncryption.GenerateRefreshToken(accessToken, 43200); // 第二个参数是刷新 token 的有效期（分钟），默认三十天
            var data = new LoginDto();
            data.accessToken = accessToken;
            data.refreshToken = refreshToken;

            Oops.Oh("用户名或密码错误");
            //  Oops.Oh("错误");
            // throw JsonResult(data);
            throw Oops.Oh("3333333333333333333333333333");
            var dats = new DataTable();
            dats.Rows[222][0].ToString();
            return data;
        }
    }
}
